/*
 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * openFuyao is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

// Package config provides configuration management for the server.
package config

import (
	"testing"

	"openfuyao-rayservice/pkg/client/k8s"
	dbruntime "openfuyao-rayservice/pkg/database/runtime"
	"openfuyao-rayservice/pkg/server/runtime"
)

func TestNewRunConfig(t *testing.T) {
	tests := []struct {
		name string
		want *RunConfig
	}{
		{
			name: "default",
			want: &RunConfig{
				Server:        runtime.NewServerConfig(),
				DbConfig:      dbruntime.NewDbConfig(),
				KubernetesCfg: k8s.NewKubernetesCfg(),
			},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := NewRunConfig(); got == nil {
				t.Errorf("NewRunConfig() = %v, want %v", got, tt.want)
			}
		})
	}
}

func TestRunConfigValidate(t *testing.T) {
	type fields struct {
		Server        *runtime.ServerConfig
		DbConfig      *dbruntime.DbConfig
		KubernetesCfg *k8s.KubernetesCfg
	}
	tests := []struct {
		name   string
		fields fields
		want   []error
	}{
		{
			name: "default",
			fields: fields{
				Server:        runtime.NewServerConfig(),
				DbConfig:      dbruntime.NewDbConfig(),
				KubernetesCfg: k8s.NewKubernetesCfg(),
			},
			want: []error{},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			cfg := &RunConfig{
				Server:        tt.fields.Server,
				DbConfig:      tt.fields.DbConfig,
				KubernetesCfg: tt.fields.KubernetesCfg,
			}
			if got := cfg.Validate(); len(got) != len(tt.want) {
				t.Errorf("RunConfig.Validate() = %v, want %v", got, tt.want)
			}
		})
	}
}
